<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <%layout("/WEB-INF/view/common/inc/admin_head.html",{title:'', styles:'bootstrap,font-awesome,animate,style,bootstrap-table,layui-date,auto-complete,dtvalidate,layui'}){%>
    <style type="text/css">
        body{padding-top:10px;}
        *{margin:0;padding:0;list-style-type:none;}
        a,img{border:0;}
        .demo h2{font-size:16px;color:#3366cc;height:30px;}
        .demo li{float:left;}
    </style>
    <%}%>
</head>

<body>
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="col-sm-12">
            <!-- START 右侧数据 -->
            <div class="ibox float-e-margins" style="margin-bottom: 0px;">
                <div class="ibox-content" style="padding:15px 20px 0px 20px;">
                    <form id="search-form" role="form" class="form-horizontal" autocomplete="off">
                        <div class="form-group">
                            <label class="control-label col-sm-1">HS CODE:</label>
                            <div class="col-sm-2">
                                <input type="text" name="hSCode" class="form-control">
                            </div>
                            <label class="control-label col-sm-1">国家:</label>
                            <div class="col-sm-2">
                                <select id="countryCode" name="countryCode"  class="form-control">
                                    <option value="">全部分类</option>
                                    <%for(var dict in country){%>
                                    <option value="${dict.detailCode}"  >${dict.detailName}</option>
                                    <%}%>
                                </select>
                            </div>
                            <a class="search-btn btn btn-success" style="margin-bottom: 0px;">查询</a>
                        </div>

                    </form>
                </div>
            </div>
            <form>
                <div id="toolbar" class="btn-group" style="margin-bottom:5px;">
                    &nbsp;
                    <a class="add-btn btn btn-sm btn-success"><i class="fa fa-plus" aria-hidden="true"></i> 新增</a>
                    <button  class="export-btn layui-btn  layui-btn-sm" style="margin-top: -6px;margin-left: -4px">
                        <i class="fa fa-download" aria-hidden="true"></i> 导出当前数据
                    </button>
                </div>
            </form>

    <!-- START 数据表格 -->
    <table id="taxTable"
           data-toolbar="#toolbar"
           data-pagination="true"
           data-resizable="true"
           data-side-pagination="server"
           data-url="/sea/physical/taxRate/findByCnd.do"
           data-page-size="15"
           class="table table-striped table-hover"
           >
    </table>

    </div>
</div>
</div>
<!-- END 数据表格 -->
<%layout("/WEB-INF/view/common/inc/admin_js.html",{modules:'jquery,bootstrap,bootstrap-table,dtvalidate,dtvalidate-lang-zh_cn,bootstrap-table-zh-CN,laydate,layer'}){}%>
<script>
    var $taxTable = $('#taxTable');
    $(function () {
        // START 表格配置
        $taxTable.bootstrapTable({
            pageSize:10,
            columns: [
                {
                    title: '国家',
                    field: 'countryName',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: 'HS Code',
                    field: 'hSCode',
                    align: 'center',
                    valign: 'middle'
                },
                {
                    title: '报关税率',
                    field: 'customsRate',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r,i) {
                        // v = Number(v*100).toFixed(2);
                        return v + '%';
                    }
                },
                {
                    title: '清关税率',
                    field: 'clearRate',
                    align: 'center',
                    valign: 'middle',
                    formatter:function (v,r,i) {
                        // v = Number(v*100).toFixed(2);
                        return v +'%';
                    }
                },
                {
                    title: '操作',
                    field: 'operate',
                    align: 'center',
                    valign: 'middle',
                    formatter: optFormatter
                }
            ],
            onLoadSuccess : function(){
                //新增
                $('.edit-btn').on('click',function(){//新增
                    var id=$(this).attr("data-val");
                    layer.open({
                        type: 2,
                        area: ['100%','100%'],
                        skin: 'layer-ext-espresso',
                        content: ['/sea/physical/taxRate/editPage.do?id='+id, 'yes']
                    });
                });
                // 删除
                $('.del-btn').on('click',function () {
                    var id = $(this).attr('data-val');
                    layer.confirm('确定删除？', {
                        btn: ['确定','取消'],title:'提示'
                    }, function(){
                        $.post('/sea/physical/taxRate/delete.do',{id: id},function(data){
                            if( data.ok ){
                                $("#taxTable").bootstrapTable('refresh');
                                layer.msg(data.msg,{icon: 1,time: 1500});
                            }else{
                                layer.msg(data.msg,{icon: 0,time: 1500});
                            }
                        });
                    });
                });
            }
        });

        // 条件查询
        $('.search-btn').on('click',function () {
            $taxTable.bootstrapTable('refresh', { url:'${ctxPath}/sea/physical/taxRate/findByCnd.do?'+$('#search-form').serialize() });
        });
    });

    // 操作菜单
    function optFormatter(value,row){
        var content = '<button class="edit-btn btn btn-xs btn-info" data-val="'+row.id+'" title="修改"><i class="fa fa-edit"></i>  </button>';
        content += '<button class="del-btn btn btn-xs btn-danger" data-val="'+row.id+'" title="删除"><i class="fa fa-trash-o"></i>  </button>';
        return content;
    }

    //新增
    $('.add-btn').on('click',function(){//新增
        layer.open({
            type: 2,
            area: ['100%','100%'],
            skin: 'layer-ext-espresso',
            content: ['/sea/physical/taxRate/addPage.do', 'yes']
        });
    });

    $(".export-btn").click(function () {
        window.location.href='/sea/physical/taxRate/export.do?'+$('#search-form').serialize();
    });
</script>
</body>
</html>
